package com.yuchen.utils;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 *
 */
public class ReflectionUtils {



    public static <T> Class<T> getSuperClassGenricType(Class clazz) {
        return   getSuperClassGenricType(clazz,0);
    }

    public static Class getSuperClassGenricType(final Class clazz, final int index) {
        Type genType = clazz.getGenericSuperclass();
        if (!(genType instanceof ParameterizedType)) {
           /* logger.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType ");*/
            return Object.class;
        }

        Type[] params = ((ParameterizedType) genType).getActualTypeArguments();

        if (index >= params.length || index < 0) {
            /*logger.warn("Index: " + index + ", Size of "
                    + clazz.getSimpleName() + "'s Parameterized Type: "
                    + params.length);*/
            return Object.class;
        }
        if (!(params[index] instanceof Class)) {
          /*  logger
                    .warn(clazz.getSimpleName()
                            + " not set the actual class on superclass generic parameter");*/
            return Object.class;
        }
        return (Class) params[index];
    }

    public static Object invokeGetterMethod(Object obj,String propertyName){
       // String getterMethodName = "get" + StringUtils.capitalize(propertyName);

        return null;
    }

    public static Method getAccessibleMethod(){
        return null;
    }


}


